home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / gdb < prev    next >
Encoding:
Text File  |  2010-11-16  |  1.3 KB  |  44 lines

  1. # bash completion for gdb
  2.  
  3. have gdb &&
  4. _gdb()
  5. {
  6.     local cur prev
  7.  
  8.     COMPREPLY=()
  9.     _get_comp_words_by_ref cur prev
  10.  
  11.     if [ $COMP_CWORD -eq 1 ]; then
  12.         local IFS
  13.         if [[ "$cur" == */* ]]; then
  14.             # compgen -c works as expected if $cur contains any slashes.
  15.             IFS=$'\n'
  16.             COMPREPLY=( $( PATH="$PATH:." compgen -d -c -- "$cur" ) )
  17.         else
  18.             # otherwise compgen -c contains Bash's built-in commands,
  19.             # functions and aliases. Thus we need to retrieve the program
  20.             # names manually.
  21.             IFS=":"
  22.             local path_array=( $( \
  23.                 sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH" ) )
  24.             IFS=$'\n'
  25.             COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \
  26.                 -mindepth 1 -maxdepth 1 -not -type d -executable \
  27.                 -printf "%f\\n" 2>/dev/null)' -- "$cur" ) )
  28.         fi
  29.     elif [ $COMP_CWORD -eq 2 ]; then
  30.         prev=${prev##*/}
  31.         COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \
  32.             awk '{if ($1 ~ /^'"$prev"'/) print $2}' )" -- "$cur" ) )
  33.     fi
  34. } &&
  35. complete -F _gdb -o default gdb
  36.  
  37. # Local variables:
  38. # mode: shell-script
  39. # sh-basic-offset: 4
  40. # sh-indent-comment: t
  41. # indent-tabs-mode: nil
  42. # End:
  43. # ex: ts=4 sw=4 et filetype=sh
  44.